package com.example.administrator.myapplication.util;

import android.content.Context;
import android.content.SharedPreferences;

import com.example.administrator.myapplication.TwoActivity;

/**
 * Created by Administrator on 2020/12/7.
 */
//sp工具类
public class saveqq {
    //保存数据 第一个参数上下文，第二个参数key，第三个参数value
    public static boolean save(Context context, String key, String value) {
        SharedPreferences sharedPreferences = context.getSharedPreferences("data", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putString(key, value);
        editor.commit();
        return true;

    }


    //获取数据
    public static String getSaveString(Context context, String key) {
        SharedPreferences sharedPreferences = context.getSharedPreferences("data", Context.MODE_PRIVATE);

        String value = sharedPreferences.getString(key, "暂无数据");

        return value;

    }

}